<template>
  <div class="contact">
    <div class="page-header">
      <h1>{{ $t('contact.title') }}</h1>
      <p>{{ $t('contact.subtitle') }}</p>
    </div>

    <div class="contact-container">
      <!-- 联系信息 -->
      <div class="contact-info">
        <h2>{{ $t('contact.info.title') }}</h2>
        <div class="info-items">
          <div class="info-item">
            <div class="info-icon">
              <el-icon :size="24"><Location /></el-icon>
            </div>
            <div class="info-content">
              <h3>地址</h3>
              <p>江苏省无锡市江阴市长山大道55号A2栋7层</p>
            </div>
          </div>
          
          <div class="info-item">
            <div class="info-icon">
              <el-icon :size="24"><Phone /></el-icon>
            </div>
            <div class="info-content">
              <h3>电话</h3>
              <p>+86-17016303333</p>
            </div>
          </div>
          
          <div class="info-item">
            <div class="info-icon">
              <el-icon :size="24"><Message /></el-icon>
            </div>
            <div class="info-content">
              <h3>邮箱</h3>
              <p>82880268@qq.com</p>
            </div>
          </div>
          
          <div class="info-item">
            <div class="info-icon">
              <el-icon :size="24"><Clock /></el-icon>
            </div>
            <div class="info-content">
              <h3>{{ $t('contact.info.hours.title') }}</h3>
              <p>{{ $t('contact.info.hours.value') }}</p>
            </div>
          </div>
        </div>

        <!--<div class="social-links">-->
          <!--<h3>关注我们</h3>-->
          <!--<div class="social-buttons">-->
            <!--<el-button type="primary" icon="Facebook" circle>Facebook</el-button>-->
            <!--<el-button type="success" icon="Message" circle>微信</el-button>-->
          <!--</div>-->
        <!--</div>-->
      </div>

      <!-- 联系表单 -->
      <!--<div class="contact-form">-->
        <!--<h2>{{ $t('contact.form.title') }}</h2>-->
        <!--<el-form -->
          <!--:model="contactForm" -->
          <!--:rules="contactRules" -->
          <!--ref="contactFormRef" -->
          <!--label-width="100px"-->
          <!--@submit.prevent="submitForm"-->
        <!--&gt;-->
          <!--<el-form-item label="姓名" prop="name">-->
            <!--<el-input v-model="contactForm.name" placeholder="请输入您的姓名" />-->
          <!--</el-form-item>-->
          <!---->
          <!--<el-form-item label="邮箱" prop="email">-->
            <!--<el-input v-model="contactForm.email" placeholder="请输入您的邮箱" />-->
          <!--</el-form-item>-->
          <!---->
          <!--<el-form-item label="电话" prop="phone">-->
            <!--<el-input v-model="contactForm.phone" placeholder="请输入您的电话号码" />-->
          <!--</el-form-item>-->
          <!---->
          <!--<el-form-item label="主题" prop="subject">-->
            <!--<el-select v-model="contactForm.subject" placeholder="请选择咨询主题">-->
              <!--<el-option label="考试咨询" value="exam" />-->
              <!--<el-option label="课程咨询" value="course" />-->
              <!--<el-option label="工作咨询" value="job" />-->
              <!--<el-option label="技术问题" value="technical" />-->
              <!--<el-option label="其他" value="other" />-->
            <!--</el-select>-->
          <!--</el-form-item>-->
          <!---->
          <!--<el-form-item label="消息内容" prop="message">-->
            <!--<el-input -->
              <!--v-model="contactForm.message" -->
              <!--type="textarea" -->
              <!--:rows="6"-->
              <!--placeholder="请详细描述您的问题或需求"-->
            <!--/>-->
          <!--</el-form-item>-->
          <!---->
          <!--<el-form-item>-->
            <!--<el-button type="primary" @click="submitForm" :loading="submitting">-->
              <!--{{ $t('contact.form.submit') }}-->
            <!--</el-button>-->
            <!--<el-button @click="resetForm">-->
              <!--{{ $t('contact.form.reset') }}-->
            <!--</el-button>-->
          <!--</el-form-item>-->
        <!--</el-form>-->
      <!--</div>-->
    </div>

    <!-- 地图区域 -->
    <div class="map-section">
      <h2>{{ $t('contact.map.title') }}</h2>
      <div class="map-container">
        <div class="map-placeholder">
          <el-icon :size="60"><Location /></el-icon>
          <p>我们的办公地址</p>
          <p class="map-address">江苏省无锡市江阴市长山大道55号A2栋7层</p>
        </div>
      </div>
    </div>

    <!-- FAQ 常见问题 -->
    <div class="faq-section">
      <h2>{{ $t('contact.faq.title') }}</h2>
      <div class="faq-list">
        <el-collapse v-model="activeNames">
          <el-collapse-item 
            v-for="faq in faqs" 
            :key="faq.id" 
            :title="faq.question" 
            :name="faq.id"
          >
            <p>{{ faq.answer }}</p>
          </el-collapse-item>
        </el-collapse>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { ElMessage } from 'element-plus'
import { 
  Location, 
  Phone, 
  Message, 
  Clock 
} from '@element-plus/icons-vue'

const { t } = useI18n()

// 表单数据
const contactForm = ref({
  name: '',
  email: '',
  phone: '',
  subject: '',
  message: ''
})

// 表单验证规则
const contactRules = {
  name: [
    { required: true, message: '请输入姓名', trigger: 'blur' },
    { min: 2, max: 20, message: '姓名长度在 2 到 20 个字符', trigger: 'blur' }
  ],
  email: [
    { required: true, message: '请输入邮箱', trigger: 'blur' },
    { type: 'email', message: '请输入正确的邮箱格式', trigger: 'blur' }
  ],
  phone: [
    { required: true, message: '请输入电话号码', trigger: 'blur' }
  ],
  subject: [
    { required: true, message: '请选择咨询主题', trigger: 'change' }
  ],
  message: [
    { required: true, message: '请输入消息内容', trigger: 'blur' },
    { min: 10, max: 500, message: '消息内容长度在 10 到 500 个字符', trigger: 'blur' }
  ]
}

const contactFormRef = ref()
const submitting = ref(false)
const activeNames = ref(['1'])

// FAQ数据
const faqs = ref([
  {
    id: '1',
    question: '如何开始学习特定技能考试？',
    answer: '您可以通过我们的网站下载免费学习资料，观看视频课程，或者参加我们的培训课程。我们提供从基础到高级的完整学习体系。'
  },
  {
    id: '2',
    question: '考试费用是多少？',
    answer: '不同考试的费用不同，具体费用请查看我们的考试介绍页面或联系我们的客服人员获取详细信息。'
  },
  {
    id: '3',
    question: '如何申请工作机会？',
    answer: '您可以在工作机会页面浏览职位信息，选择感兴趣的职位进行申请。我们会在收到申请后尽快与您联系。'
  },
  {
    id: '4',
    question: '提供哪些语言支持？',
    answer: '我们提供中文和日文双语支持，所有课程和资料都有对应的语言版本。'
  },
  {
    id: '5',
    question: '如何联系客服？',
    answer: '您可以通过电话、邮箱或在线表单联系我们。我们的客服团队会在工作时间内及时回复您的问题。'
  }
])

// 提交表单
const submitForm = async () => {
  try {
    await contactFormRef.value.validate()
    
    submitting.value = true
    
    // 模拟提交过程
    await new Promise(resolve => setTimeout(resolve, 2000))
    
    ElMessage.success('消息发送成功！我们会尽快与您联系。')
    
    // 重置表单
    resetForm()
    
  } catch (error) {
    ElMessage.error('请检查表单信息')
  } finally {
    submitting.value = false
  }
}

// 重置表单
const resetForm = () => {
  contactForm.value = {
    name: '',
    email: '',
    phone: '',
    subject: '',
    message: ''
  }
  contactFormRef.value?.resetFields()
}
</script>

<style scoped>
.contact {
  padding: 20px 0;
}

.page-header {
  text-align: center;
  margin-bottom: 60px;
}

.page-header h1 {
  font-size: 2.5rem;
  color: #2c3e50;
  margin-bottom: 10px;
}

.page-header p {
  font-size: 1.1rem;
  color: #666;
}

.contact-container {
  max-width: 600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr ;
  gap: 60px;
  padding: 0 20px;
  margin-bottom: 60px;
}

.contact-info {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.contact-info h2 {
  font-size: 1.8rem;
  color: #2c3e50;
  margin-bottom: 30px;
}

.info-items {
  display: flex;
  flex-direction: column;
  gap: 25px;
  margin-bottom: 40px;
}

.info-item {
  display: flex;
  gap: 15px;
  align-items: flex-start;
}

.info-icon {
  color: #409EFF;
  margin-top: 5px;
}

.info-content h3 {
  margin: 0 0 8px 0;
  color: #2c3e50;
  font-size: 1.1rem;
}

.info-content p {
  margin: 0;
  color: #666;
  line-height: 1.5;
}

.social-links h3 {
  margin: 0 0 15px 0;
  color: #2c3e50;
  font-size: 1.1rem;
}

.social-buttons {
  display: flex;
  gap: 15px;
}

.contact-form {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.contact-form h2 {
  font-size: 1.8rem;
  color: #2c3e50;
  margin-bottom: 30px;
}

.map-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  margin-bottom: 60px;
}

.map-section h2 {
  text-align: center;
  font-size: 2rem;
  color: #2c3e50;
  margin-bottom: 30px;
}

.map-container {
  background: #f8f9fa;
  border-radius: 12px;
  overflow: hidden;
  height: 400px;
}

.map-placeholder {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #999;
  text-align: center;
}

.map-placeholder p {
  margin: 15px 0 5px 0;
  font-size: 1.1rem;
}

.map-address {
  font-size: 0.9rem !important;
  color: #666 !important;
}

.faq-section {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
}

.faq-section h2 {
  text-align: center;
  font-size: 2rem;
  color: #2c3e50;
  margin-bottom: 30px;
}

.faq-list {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  overflow: hidden;
}

.faq-list :deep(.el-collapse-item__header) {
  font-size: 1.1rem;
  color: #2c3e50;
  padding: 20px;
}

.faq-list :deep(.el-collapse-item__content) {
  padding: 0 20px 20px 20px;
  color: #666;
  line-height: 1.6;
}

@media (max-width: 768px) {
  .contact-container {
    grid-template-columns: 1fr;
    gap: 30px;
  }
  
  .contact-info,
  .contact-form {
    padding: 30px 20px;
  }
  
  .social-buttons {
    justify-content: center;
  }
  
  .map-container {
    height: 300px;
  }
}
</style> 